import type {ExtractPropTypes, PropType} from 'vue'
import {buildProps} from "../../../utils";

export interface SearchList {
  label: string;
  key: string | string[];
  type: 'slot' | 'input' | 'select' | 'cascader' | 'datePicker'; // 类型
  elFormItemAttrs?: Record<string, any>; // el-form-item 可绑定的数据信息
  elColAttrs?: object; // 自定义当前筛选项自适应比例
  defaultCollapse?: boolean; // 是否默认折叠
  isHidden?: boolean; // 是否隐藏当前项
  devAttrs?: Record<string, any>; // 当前组件可以选择的参数，具体信息可以前往devecoui官网查看
}

export const devSearchFormProps = buildProps({
  searchList: {
    type: Array as PropType<SearchList[]>,
    default: []
  },
  formValue: {
    type: Object as PropType<{ [key: string]: any }>,
    default: {}
  },
  elColAttrs: {
    type: Object as PropType<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', number>>,
    default: () => ({
      xs: 24,
      sm: 12,
      md: 8,
      lg: 8,
      xl: 6,
    }),
  },
  isCollapse: {
    type: Boolean,
    default: false
  },
  elFormAttrs: {
    type: Object,
    default: () => ({})
  },
  submitBtnText: {
    type: String,
    default: '查询'
  },
  resetBtnText: {
    type: String,
    default: '重置'
  },
  // 是否开启回车按钮搜索
  enterToSearch:{
    type: Boolean,
    default: true
  }
} as const)
export type DevSearchFormProps = ExtractPropTypes<typeof devSearchFormProps>
